<template>
  <view>
    <!-- 搜索框 -->
    <ugo-search></ugo-search>
    <!-- 轮播图 -->
    <u-swiper :list="list" name="image_src" :height="340"></u-swiper>
    <!-- 导航 -->
    <view class="nav u-flex">
      <navigator v-for="item in navList" :key="item.name" class="u-flex-1 u-p-20">
        <u-image width="100%" mode="widthFix" :src="item.image_src"></u-image>
      </navigator>
    </view>
    <!-- 楼层 -->
    <view class="floor">
      <view class="floor-group" v-for="item1 in floorList" :key="item1.floor_title.name">
        <!-- 标题 -->
        <view class="floor-group-title">
          <u-image
            width="100%"
            mode="widthFix"
            margin-top="10"
            margin-bottom="20"
            :src="item1.floor_title.image_src"
          ></u-image>
        </view>
        <!-- 内容 -->
        <view class="floor-group-content">
          <navigator v-for="item2 in item1.product_list" :key="item2.name">
            <u-image width="100%" mode="scallToFill" height="100%" :src="item2.image_src"></u-image>
          </navigator>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 轮播图数组
      list: [],
      // 导航数组
      navList: [],
      // 楼层数组
      floorList: []
    };
  },
  async onLoad() {
    // 轮播图的请求
    const res = await this.$u.get("/home/swiperdata");
    this.list = res.message;
    const result = await this.$u.get("/home/catitems");
    this.navList = result.message;
    const str = await this.$u.get("/home/floordata");
    this.floorList = str.message;
  },
  methods: {}
};
</script>

<style lang="scss">
.floor-group-title {
  margin-bottom: 20rpx;
}
.floor-group-content {
  // margin-top: 10rpx;
  // margin-bottom: 20rpx;
  navigator {
    width: 232rpx;
    float: left;
    height: 188rpx;
    margin-left: 15rpx;
  }
  navigator:nth-child(1) {
    height: 386rpx;
  }
  /* 后两个导航标签 */
  navigator:nth-last-child(-n + 2) {
    margin-top: 15rpx;
  }
}
</style>
